<template>
	<view class="full-page" v-if="totalPage">
		
	</view>
	<view class="content" v-else>
		<u-navbar bgColor="#fff" :placeholder="true" :fixed="true" @leftClick="$back" title="举报记录" titleStyle="{'color': '#000'}">
			
		</u-navbar>
		
		<view class="empytView" v-if="recordList.length <=0">
			<image :src="'/images/kong.png' | formatImgUrl" mode="widthFix" />
			<!-- <view>- 空列表 -</view> -->
		</view>

		<view class="xunli" v-for="(item, index) in recordList" :key="index">
			<view class="topbox" @click="change(index)">
				<view class="time">
					{{$options.filters.parseTime(item.create_time,'{y} 年 {m} 月 {d} 日')}}
				</view>
				<view class="txt" :class="{active : item.status}">
					{{item.status}}
				</view>
				<image :src="'/images/arrow1.png' | formatImgUrl" :class="{xuan : item.xuan}" class="rarr" mode=""
					v-if="item.open"></image>
				<image :src="'/images/arrow2.png' | formatImgUrl" :class="{xuan : item.xuan}" class="rarr" mode=""
					v-else></image>
			</view>

			<view class="yinbox" v-if="item.open">
				<block v-if="item.err_cnt">
					<view class="yintitle">
						申诉反馈
					</view>
					<view class="dengtxt">
						登记号：{{item.id}}
					</view>

					<view class="daotxt" style="margin-bottom: 10px;">
						{{item.err_cnt}}
					</view>

					<view class="original">

						<view class="display-flex original-top">
							<image :src="userInfo.pic | formatImgUrl" mode="aspectFill"></image>
							<view class="">
								{{userInfo.username?userInfo.username:'默认昵称'}}
								<view class="reason-txt">
									申诉理由：{{item.e_title}}
								</view>
							</view>
						</view>
						<view class="daotxt" style="margin-top: 10px;">
							{{item.e_desc}}
						</view>
						<view class="img display-flex">
							<image :src="item | formatImgUrl" class="fupic" mode="widthFix"
								v-for="item in item.images_arr" @click="dianji(item)"></image>

						</view>
					</view>
				</block>
				<block v-else>
					<!-- <view class="yintitle">
						申诉反馈
					</view>
					<view class="dengtxt">
						登记号：{{item.id}}
					</view>
					<view class="daotxt">
						{{item.e_title}}
					</view>
					<view class="daotxt">
						{{item.e_desc}}
					</view>
					<view class="img display-flex">
						<image :src="item | formatImgUrl" class="fupic" mode="aspectFill" v-for="item in item.images_arr"
							@click="dianji(item)"></image>
					</view> -->
					
					<view class="original" style="padding: 0;background-color: #fff;">
					
						<view class="display-flex original-top">
							<image :src="userInfo.pic | formatImgUrl" mode="aspectFill"></image>
							<view class="">
								{{userInfo.username?userInfo.username:'默认昵称'}}
								<view class="reason-txt">
									申诉理由：{{item.e_title}}
								</view>
							</view>
						</view>
						<view class="daotxt" style="margin-top: 10px;">
							{{item.e_desc}}
						</view>
						<view class="img display-flex">
							<image :src="item | formatImgUrl" class="fupic" mode="widthFix"
								v-for="item in item.images_arr" @click="dianji(item)"></image>
					
						</view>
					</view>
				</block>
			</view>
		</view>


	</view>
</template>
<script>
	import Config from "@/common/config.js"
	export default {
		data() {
			return {

				list: {},
				recordList: [],
				page: 1,
				datas: null,
				itemStyle: {},
				userInfo: this.$db.get('userInfo'),
				totalPage: true
			}
		},
		onLoad() {

		},
		onShow() {
			this.getList()
		},
		// 上拉加载
		onReachBottom() {
			if (this.list.current_page < this.list.last_page) {
				this.page++; // 页数加一，加载下一页数据
				this.getList();
			}
		},
		methods: {
			change(ix) {
				this.recordList[ix].open = !this.recordList[ix].open
				this.$forceUpdate()
			},
			dianji(photoImg) {
				console.log(Config.CdnUrl + photoImg, 777)

				let imgsArray = [];
				imgsArray[0] = Config.CdnUrl + photoImg;
				uni.previewImage({
					current: 0,
					urls: [photoImg]
				});

			},
			getList() {
				this.$api.default.request('user/reportList_new').then((res) => {
					if (res.code) {
						this.list = res.data
						if (res.current_page > 1) {
							res.data.data.forEach((item) => {
								item.open = false
								this.recordList.push(item)
							})
						} else {
							res.data.data.forEach((item) => {
								item.open = false
							})

							if (res.data.data.length == 1) {
								res.data.data[0].open = true
							}
							this.recordList = res.data.data
						}
					}
					
					this.totalPage = false
				})
			},
			shownei(index) {

				this.datas = index;
				// this.recordList[index].isShow = !this.recordList[index].isShow
				// var s = this.recordList[index]
				// this.recordList = [];
				// this.recordList = s

			},
		}
	}
</script>

<style lang="scss">
	.original {
		background: #F8F8F8;
		padding: 20rpx 30rpx;
		border-radius: 4px;

		.original-top {
			font-family: '思源黑体';
			font-size: 14px;
			font-weight: bold;
			color: #3D3D3D;

			image {
				width: 40px;
				height: 40px;
				border-radius: 50%;
				margin-right: 6px;
			}

			.reason-txt {
				margin-top: 3px;
				font-size: 12px;
				color: #999999;
			}
		}
	}


	page {
		background: rgba(242, 245, 242, 1);
	}

	.content {
		padding-top: 20rpx;

		.xunli {
			background-color: #ffffff;
			margin-bottom: 20rpx;

			.topbox {
				padding: 40rpx 68rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.time {
					font-size: 28rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
					flex-shrink: 0;
				}

				.txt {
					flex-grow: 1;
					font-size: 28rpx;
					font-weight: normal;
					text-align: right;
					color: #999999;
					padding: 0 20rpx;
				}

				.active {
					color: #45C4B0;
				}

				.rarr {
					width: 40rpx;
					height: 40rpx;
					flex-shrink: 0;
				}

				.xuan {
					transform: rotate(90deg);
				}
			}

			.yinbox {
				box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.03) inset;
				padding: 40rpx 30rpx;

				.img {
					flex-wrap: wrap;
				}

				.img image {
					width: 77px;
					height: 77px;
					margin-right: 3px;
					margin-bottom: 3px;

					&:nth-of-type(4n) {
						margin-right: 0px;
					}
				}

				.yintitle {
					font-size: 32rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
				}

				.dengtxt {
					font-size: 24rpx;
					font-weight: normal;
					letter-spacing: 0em;
					color: #999999;
					padding-bottom: 12rpx;
					margin-top: 5px;
				}

				.daotxt {
					font-size: 24rpx;
					font-weight: normal;
					letter-spacing: 0em;
					color: #3D3D3D;
					line-height: 34rpx;
					
				}
			}
		}
	}
</style>